
<div id="main">
<div id="contents">
<form name="filters"  method="post" >
<fieldset>
<legend>
     <label sid="softupload.param1"></label>
</legend>
<div class="frame_tab_layer">
<span id="loading" style="display:none;"><img src="images/load.gif"/>
    <label sid="softupload.progress"></label></span>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="cmenutitle">
<tr>
<td  colspan="2" align="center">
    <input sid="softupload.button2" class="button" type="button" name="submit"/>&#160;&#160;&#160;&#160;
    <input sid="softupload.button1" class="button" type="button" name="cancel"/>
</tr>
</table>
</div>
</fieldset>
</form>
</div>
</div>
<br/>
<div id="helpContainer">
<div id="help">
<div><h2><img src="images/help_title.png" border="0"><label sid="share.help"></label></h2></div>
<dl>
<dt class="term"><label sid="softupload.param1"></label></dt>
<dd class="definition">
    <label sid="softupload.param4"></label>
</dd>
</dl>
</div>
</div>

<script type="text/javascript" src="js/message_panel.js"></script>
<script type="text/javascript" src="js/ajaxfileupload.js"></script>
<script type="text/javascript">
    function resets() {
        loadNewHtml("softupload_main_load.htm");
}

function startupgrade() {
    var timer = '';
    $("[name=submit]").attr("disabled", true);
    $("#loading").show();
    report = function (message) {
        $.ajaxFileUpload({
            url: 'upgrade',
            data: 'upgrade=upgrade',
            dataType: 'xml',
            error: function (data, status, e) {
                $(data).find('Error').each(function () {
                    var errortext = $(this).attr('msg');
                    //show_message("err",errortext);
                    alert(errortext);
                });
            },
            success: function (data, status) {
                var stat = $(data).find("rsp").attr("stat");
                if (stat == "ok") {
                    $("[name=submit]").attr("disabled", false);
                    $("#loading").hide();
                    clearInterval(timer);
                  // show_message("err",softupload.okr);
                  alert(softupload.okr);
                    top.location.href = "index.htm";
                } else if (stat == "inprogress") {
                    $("#loading").show();
                } else if (stat == "fail") {
                    $("[name=submit]").attr("disabled", false);
                    $("#loading").hide();
                    clearInterval(timer);
                    var error = $(data).find("error").text();
                   // show_message("err",softupload.upfail);
                   alert(softupload.upfail);
                    loadNewHtml("softupload_main_load.htm");

                }
            }
        });
    }
    timer = setInterval(report, 5000);
}

    window.onbeforeunload = function () {
        $.ajax({
            type: "POST",
            url: 'cancelupgrade',
            data: 'cancelupgrade=cancelupgrade',
            dataType: 'xml',
            error: function (xml) {
                $(xml).find('Error').each(function () {
                    var errortext = $(this).attr('msg');
                   // show_message("err",errortext);
                   alert(errortext);
                });
            }
        });
    }
    $("[name=submit]").click(function () {
        startupgrade();
    });
    
    $("[name=cancel]").click(function () {
        resets();
    });
</script>
</body>
</html>
